package com.ruoyi.web.controller.tzzl;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.tzzl.domain.WzComment;
import com.ruoyi.tzzl.service.IWzCommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 动态评论Controller
 * @author by caoyong
 * @date 2022/11/18
 **/
@RestController
@RequestMapping("/tzzl/comments")
public class WzCommentsController extends BaseController {

    @Autowired
    private IWzCommentsService wzCommentsService;

    /**添加评论*/
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WzComment wzComment){
        return AjaxResult.success(wzCommentsService.addComment(wzComment));
    }

    /**回复评论*/
    @PostMapping("/reply")
    public AjaxResult reply(@RequestBody WzComment wzComment){
        return AjaxResult.success(wzCommentsService.replyToComments(wzComment));
    }

    /**
     * 删除评论
     * */
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody WzComment wzComment){
        return AjaxResult.success(wzCommentsService.removeById(wzComment.getId()));
    }

}
